package org.xtext.runtime.interpreter;

import java.util.LinkedList;
import java.util.List;

import org.xtext.runtime.formula.Predicate;
import org.xtext.runtime.term.Variable;

public class PredicateBuilder extends AbstractBuilder {
	private Predicate predicate;
	
	public PredicateBuilder(Predicate predicate) {
		super(predicate.variables());
		this.predicate = predicate;
	}
	
	public Predicate getPredicate() {
		return predicate;
	}
	
	public Predicate getGroundPredicate() {
		if (!variables.isEmpty()) {
			throw new UnboundVariablesException("[" + predicate + "] Some variables have not been bound: " + variables);
		}
	
		return getPredicate();
	}

	public List<Variable> getVariables() {
		return new LinkedList<Variable>(variables);
	}
}
